package com.yanwq.nwa.user;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.yanwq.nwa.MainActivity;
import com.yanwq.nwa.R;
import com.yanwq.nwa.entity.User;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LoginActivity extends AppCompatActivity {

    @BindView(R.id.login_username)
    EditText loginUsername;
    @BindView(R.id.login_submit)
    Button loginSubmit;
    @BindView(R.id.activity_login)
    LinearLayout activityLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.login_submit)
    public void onClick() {
        register();
    }

    private void register() {
        User user = new User();
        user.setUuid(loginUsername.getText().toString());
        UserMgr.save(user);

        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }
}
